//
//  KLBookService.h
//  KLBookStore
//
//  Created by apple on 2017/10/15.
//  Copyright © 2017年 NetEaseExam. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "KLBookEntity.h"

@interface KLBookService : NSObject

//为了提升性能 数据库操作提供异步接口
/**
 * 收藏图书
 * @param bookEntity 图书模型
 * @return 图书本地id
 */
+ (long long)favorBook:(KLBookEntity *)bookEntity;
+ (void)favorBook:(KLBookEntity *)bookEntity completion:(void (^)(long long))completionHandler;
/**
 * 删除图书
 * @param localId 图书本地id
 * @return bool
 */
+ (BOOL)deleteBookWithId:(long long)localId;
+ (void)deleteBookWithId:(long long)localId completion:(void (^)(BOOL))completionHandler;

//查询数据库中收藏的图书
+ (KLBookEntity *)searchFavoredBookWithDoubanId: (long long)doubanId;
+ (void)searchFavoredBookWithDoubanId: (long long)doubanId completion:(void (^)(KLBookEntity *))completionHandler;

/**
 * 查询所有图书
 * @return 图书数组
 */
+ (NSArray <KLBookEntity *>*)getAllBookEntities;
+ (void)getAllBookEntitiesWithCompletion:(void (^)(NSArray<KLBookEntity *>*))completionHandler;
/**
 * 查询部分图书
 * @param offset size
 * @return 图书数组
 */
+ (NSArray <KLBookEntity *>*)getBookEntitiesWithOffset:(long long)offset pageSize:(NSUInteger)size;
+ (void)getBookEntitiesWithOffset:(long long)offset pageSize:(NSUInteger)size completion:(void (^)(NSArray<KLBookEntity *>*))completionHandler;

@end
